home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 201-225 / disk_223 / ifftosun / jiff.h < prev    next >
C/C++ Source or Header  |  1992-05-06  |  4KB  |  161 lines

  1.  
  2. /************ I usually put these in a file called format.h ****/
  3.  
  4. #define LO_RES
  5.  
  6. #ifdef HI_RES
  7. #define XMAX 640
  8. #define YMAX 200
  9. #define PLANES 4
  10. #define MAXCOL (1<<PLANES)
  11. #define XASPECT 5
  12. #define YASPECT 11
  13. #endif HI_RES
  14.  
  15. #ifdef LO_RES
  16. #define XMAX 320
  17. #define YMAX 200
  18. #define PLANES 5
  19. #define MAXCOL (1<<PLANES)
  20. #define XASPECT 10
  21. #define YASPECT 11
  22. #endif LO_RES
  23.  
  24.  
  25.  
  26. /* EA handy make a long from 4 chars macros redone to work with Aztec */
  27.  
  28. #define MAKE_ID(a, b, c, d)\
  29.         ( ((long)(a)<<24) + ((long)(b)<<16) + ((long)(c)<<8) + (long)(d) )
  30.  
  31.  
  32.  
  33. /* these are the IFF types I deal with */
  34.  
  35. #define FORM MAKE_ID('F', 'O', 'R', 'M')
  36. #define ILBM MAKE_ID('I', 'L', 'B', 'M')
  37. #define BMHD MAKE_ID('B', 'M', 'H', 'D')
  38. #define CMAP MAKE_ID('C', 'M', 'A', 'P')
  39. #define BODY MAKE_ID('B', 'O', 'D', 'Y')
  40.  
  41. /* and these are the IFF types I ignore but don't squawk about */
  42.  
  43. #define GRAB MAKE_ID('G', 'R', 'A', 'B')
  44. #define DEST MAKE_ID('D', 'E', 'S', 'T')
  45. #define SPRT MAKE_ID('S', 'P', 'R', 'T')
  46. #define CAMG MAKE_ID('C', 'A', 'M', 'G')
  47. #define CRNG MAKE_ID('C', 'R', 'N', 'G')
  48. #define CCRT MAKE_ID('C', 'C', 'R', 'T')
  49.  
  50.  
  51.  
  52.  
  53.         /* Some macros for raster memory allocation ... redefine if you're
  54.                  sensible and manage memory locally */
  55.  
  56.  
  57. /* ralloc - raster alloc*/
  58.  
  59. #define ralloc(amount)  (PLANEPTR)AllocMem((long)(amount), MEMF_CHIP)
  60.  
  61.  
  62. /* rfree - raster free*/
  63.  
  64. #define rfree(pt, amount)      FreeMem( (pt), (long)(amount) )
  65.  
  66.  
  67. /*line_bytes = the number of words * 2 (for bytes) a raster line takes up */
  68.  
  69. #define line_bytes(width)      (((width+15)>>4)<<1)
  70.  
  71.  
  72. /* psize - plane size in bytes (an even number) of a raster given
  73.    width and height */
  74.  
  75. #define psize(width, height) ( line_bytes(width)*height)
  76.  
  77.  
  78. /* the place to throw excess bits */
  79. #define bit_bucket(file, length) fseek(file, (long)(length), 1)
  80.  
  81.  
  82.  
  83.  
  84. union bytes4
  85.         {
  86.         char b4_name[4];
  87.         long b4_type;
  88.         };
  89.  
  90.  
  91.  
  92. struct iff_chunk
  93.         {
  94.         union bytes4 iff_type;
  95.         long iff_length;
  96.         };
  97.  
  98.  
  99. struct form_chunk
  100.         {
  101.         union bytes4 fc_type; /* == FORM */
  102.         long fc_length;
  103.         union bytes4 fc_subtype;
  104.         };
  105.  
  106.  
  107.  
  108. struct BitMapHeader
  109.         {
  110.         UWORD w, h;
  111.         UWORD x, y;
  112.         UBYTE nPlanes;
  113.         UBYTE masking;
  114.         UBYTE compression;
  115.         UBYTE pad1;
  116.         UWORD transparentColor;
  117.         UBYTE xAspect, yAspect;
  118.         WORD pageWidth, pageHeight;
  119.         };
  120.  
  121.  
  122.  
  123. /* ILBM_info is the structure read_iff returns, and is hopefully all
  124.    you need to deal with out of the iff reader routines below */
  125.  
  126. struct ILBM_info
  127.         {
  128.         struct BitMapHeader header;
  129.         UBYTE cmap[MAXCOL*3];     /*say hey aztec don't like odd length structures*/
  130.         struct BitMap bitmap;
  131.         };
  132.  
  133.  
  134.  
  135. /* I sure wish C function "prototypes" were real and not just ANSI */
  136.  
  137. extern struct ILBM_info *read_iff();     /* read_iff( char *filename ); */
  138. extern void free_planes();               /* free_planes( struct BitMap *bitmap); */
  139. extern int write_iff();
  140.  
  141.  
  142. /* write_iff(char *name, unsigned char *colors, struct BitMap *bits,
  143.         short xoff, short yoff, short width, short compressed); */
  144.  
  145. extern char *AllocMem();
  146.  
  147.  
  148. /* Anyone know where some useful minterms are defined? */
  149. #define COPY_MINTERM           0xc0
  150.  
  151. /***
  152.               Meditation for the guru from the Diamond Sutra -
  153.  
  154.                So shall you think of all this fleeting world:
  155.                A star at dawn, a bubble in a stream;
  156.                A flash of lightning in a summer cloud,
  157.                A flickering lamp, a phantom, and a dream.
  158. ***/
  159.  
  160.  
  161.